<template>
  <div class="tab-content-wrap" v-loading="loading">
    <u-descriptions-list :column-config="descriptions" :column="1"/>
  </div>
</template>

<script>
import UDescriptionsList from '@/components/UDescriptionsList'
import {reqDeviceByDeviceCode} from "@/api/operationAndMonitoring/deviceMonitoring";

export default {
  name: "DeviceConfigInfo",
  components: {
    UDescriptionsList,
  },
  props: {
    deviceCode: {
      type: String
    }
  },
  data() {
    return {
      descriptions: [
        {label: '设备配置编码', key: 'code', span: '', value: ''},
        {label: '设备名称', key: 'name', span: '', value: ''},
        {label: '设备品牌', key: 'brandName', span: '1', value: ''},
        {label: '型号', key: 'model', span: '1', value: ''},
        {label: '规格', key: 'spec', span: '1', value: ''},
        {label: 'BOM编码', key: 'bomCode', span: '1', value: ''},
        {label: '配置数据更新时间', key: 'updateTime', span: '', value: ''}
      ],
      loading: false
    }
  },
  methods: {
    // @descriptions 获取设备配置
    async getDeviceByDeviceCode() {
      try {
        this.loading = true;
        const res = await reqDeviceByDeviceCode({
          code: this.deviceCode
        })
        if (res.data) {
          this.descriptions.map(item => {
            item.value = res.data[item.key];
            return item
          })
        } else {
          this.$modal.msgWarning("获取设备配置失败！")
        }
      } catch (err) {
        console.log("reqGetScreenshot 接口数据异常", err)
      } finally {
        this.loading = false;
      }
    },
  },
  created() {
    this.getDeviceByDeviceCode();
  },

}
</script>

<style lang="scss" scoped>

</style>
